﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using log4net;
using RealState.BusinessObjects;
using RealState.BLL;
using RealState.Utils;

namespace RealState.W.AdminControl
{
    public partial class ContentTypeC : System.Web.UI.UserControl
    {
        private ContentTypesBLL m_ContentTypeBLL;
        private ContentTypes m_ContentTypeDO;
        protected ILog log = LogManager.GetLogger(typeof(ContentTypeC));
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnSave_Click(object sender, EventArgs e)
        {
            m_ContentTypeBLL = new ContentTypesBLL();
            m_ContentTypeDO = new ContentTypes();
            try
            {
                m_ContentTypeDO.Title = txtTitle.Text;
                m_ContentTypeDO.GroupId = Int32.Parse(drpGroup.SelectedValue);
                int result = m_ContentTypeBLL.AddContentTypes(m_ContentTypeDO);
                if (result > 0)
                {
                    JavaScript.Success("Thêm mới thành công", Page, "ContentType.aspx");
                }
                else
                    JavaScript.Error("Có lỗi xảy ra ", Page);
            }
            catch (Exception ex)
            {
                log.Error(ex.Message);
            }
            finally
            {
                m_ContentTypeBLL = null;
                m_ContentTypeDO = null;
            }
        }
    }
}